<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<p:dialog id="resource_edit_dialog" widgetVar="resource_edit_var" modal="true"
		header="资源信息(新增/修改/删除/查询)" resizable="false" width="500">

		<h:form prependId="false" id="resource_edit_form">
			<p:focus context="resource_edit_form"/>
			
			<h:panelGrid columns="4" columnClasses="column1,column2,column1,column2">
				<h:outputText value="资源编码：" />
				<h:column>
					<p:inputText value="#{resourceBean.instance.code}" disabled="#{resourceBean.model eq comm.m_q}">
						<f:attribute name="label" value="资源编码："/>
						<f:attribute name="validate" value="required=yes@maxlength=50"/>
					</p:inputText>
					<h:outputText value="*" style="color: red;" />
				</h:column>
				<h:outputText value="资源名称：" />
				<h:column>
					<p:inputText value="#{resourceBean.instance.name}" disabled="#{resourceBean.model eq comm.m_q}">
						<f:attribute name="label" value="资源名称："/>
						<f:attribute name="validate" value="required=yes@maxlength=50"/>
					</p:inputText>
					<h:outputText value="*" style="color: red;" />
				</h:column>
			</h:panelGrid>
			
			<h:panelGrid columns="2" columnClasses="column1">
				<h:outputText value="资源路径：" />
				<p:inputText value="#{resourceBean.instance.url}" disabled="#{resourceBean.model eq comm.m_q}"
					style="width: 362px;">
					<f:attribute name="label" value="资源路径："/>
					<f:attribute name="validate" value="maxlength=250"/>
				</p:inputText>
			</h:panelGrid>
			
			<h:panelGrid columns="4" columnClasses="column1,column2,column1,column2">
				<h:outputText value="资源类型：" />
				<h:column>
					<h:selectOneMenu value="#{resourceBean.instance.type}" disabled="#{resourceBean.model eq comm.m_q}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all">
						<f:attribute name="label" value="资源类型："/>
						<f:attribute name="validate" value="required=yes"/>
						<f:selectItems value="#{appInfo.getDictsByRootcode(resourceBean.rootType)}" var="dict"
							itemLabel="#{dict.name}" itemValue="#{dict.value}"/>
					</h:selectOneMenu>
					<h:outputText value="*" style="color: red;" />
				</h:column>
				<h:outputText value="父资源：" />
				<h:column>
					<h:selectOneMenu value="#{resourceBean.instance.parentId}" disabled="#{resourceBean.model eq comm.m_q}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all">
						<f:attribute name="label" value="父资源："/>
						<f:attribute name="validate" value="required=yes"/>
						<f:selectItem itemLabel="无父级资源" itemValue="0"/>
						<f:selectItems value="#{resourceBean.parentResources}" var="parent"
							itemLabel="#{parent.name}" itemValue="#{parent.id}"/>
					</h:selectOneMenu>
					<h:outputText value="*" style="color: red;" />
				</h:column>
			</h:panelGrid>
			
			<h:panelGrid columns="2" columnClasses="column1">
				<h:outputText value="备注：" />
				<p:inputTextarea value="#{resourceBean.instance.remarks}" style="width: 362px; height: 50px;"
					autoResize="true" disabled="#{resourceBean.model eq comm.m_q}">
					<f:attribute name="label" value="备注："/>
					<f:attribute name="validate" value="maxlength=250"/>
				</p:inputTextarea>
				
				<h:outputText value="#{msgs.valid}：" />
				<h:selectOneRadio value="#{resourceBean.instance.status}" disabled="#{resourceBean.model eq comm.m_q}">
					<f:attribute name="label" value="#{msgs.valid}："/>
					<f:attribute name="validate" value="required=yes"/>
					<f:selectItem itemLabel="#{msgs.valid_y}" itemValue="1"/>
					<f:selectItem itemLabel="#{msgs.valid_n}" itemValue="1024"/>
				</h:selectOneRadio>
			</h:panelGrid>
			
			<div style="text-align: center;">
				<p:commandButton icon="#{comm.saveClass}" value="#{msgs.btnSave}" action="#{resourceBean.doAction}"
					oncomplete="handleResource(xhr, status, args);" update=":option_info"
					disabled="#{resourceBean.model eq comm.m_q}">
					<f:setPropertyActionListener target="#{resourceBean.formId}" value="resource_edit_form" />
				</p:commandButton>
				<p:commandButton icon="#{comm.cancelClass}" value="#{msgs.btnCancel}" type="button" onclick="resource_edit_var.hide();"/>
			</div>
		</h:form>
		<script type="text/javascript">
			function handleResource(xhr, status, args) {
				if(args.option_result == 'success') {
					resource_edit_var.hide();
				}
			}
		</script>
	</p:dialog>

</ui:composition>